package cn.bgs.wjx.WjxController;

import cn.bgs.DealershipManagement.pojo.VehicleArea;
import cn.bgs.DealershipManagement.pojo.VehicleCar;
import cn.bgs.DealershipManagement.pojo.VehicleMiddle;
import cn.bgs.DealershipManagement.pojo.VehicleNumber;
import cn.bgs.wjx.WjxService.lmpl.CarServicelmpl;
import cn.bgs.wjx.pojo.ResponseDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ProjectName: community-management_two
 * @Package: cn.bgs.xss.controller
 * @ClassName: CarController
 * @Author: Xss
 * @Description:
 * @Date: 2022/6/16 10:51
 * @Version 1.0
 */
@RestController
@RequestMapping("/app/car")
public class CarController {
    private static final Logger LOG = LoggerFactory.getLogger(CarController.class);

    @Autowired
    private CarServicelmpl vehicleMiddleService;


    //根据userId查询我的车位
    @RequestMapping("/findAllMyCar")
    public ResponseDto findAllMyCar(Integer userId){
        ResponseDto responseDto=new ResponseDto();
        List<VehicleMiddle> list=vehicleMiddleService.findAllMyCar(userId);
        responseDto.setContent(list);
        return responseDto;
    }
    //查询车位区域
    @RequestMapping("/findAllArea")
    public ResponseDto findAllArea(){
        ResponseDto responseDto=new ResponseDto();
        List<VehicleArea> list=vehicleMiddleService.findAllArea();
        responseDto.setContent(list);
        return responseDto;
    }

    //查询车位编号
    @RequestMapping("/findAllNum")
    public ResponseDto findAllNum(){
        ResponseDto responseDto=new ResponseDto();
        List<VehicleNumber> list=vehicleMiddleService.findAllNum();
        responseDto.setContent(list);
        return responseDto;
    }

    //查询车辆
    @RequestMapping("/findAllCar")
    public ResponseDto findAllCar(){
        ResponseDto responseDto=new ResponseDto();
        List<VehicleCar> list=vehicleMiddleService.findAllCar();
        responseDto.setContent(list);
        return responseDto;
    }

    //添加车位
    @RequestMapping("/addCarport")
    public ResponseDto addCarport(@RequestBody VehicleMiddle middle){
        ResponseDto responseDto=new ResponseDto();
        vehicleMiddleService.addCarport(middle);
        responseDto.setContent(middle);
        return responseDto;
    }

    //删除
    @RequestMapping("/deleteCarportUser")
    public void deleteCarportUser(Integer vehicleMiddleId,Integer vehicleCarId,Integer vehicleNumberId) {
        vehicleMiddleService.deleteCarportUser(vehicleMiddleId,vehicleCarId,vehicleNumberId);
    }

    //修改
    @RequestMapping("/updateCarportUser")
    public ResponseDto updateCarportUser(@RequestBody VehicleMiddle middle){
        System.out.println("---------------"+middle);
        ResponseDto responseDto=new ResponseDto();
        vehicleMiddleService.updateCarportUser(middle);
        responseDto.setContent(middle);
        return responseDto;
    }

    //取消绑定  车辆 车位updateCancleBinding
    @RequestMapping("/updateCancleBinding")
    public ResponseDto updateCancleBinding(@RequestBody VehicleMiddle middle){
        System.out.println("---------------"+middle);
        ResponseDto responseDto=new ResponseDto();
        vehicleMiddleService.updateCancleBinding(middle);
        responseDto.setContent(middle);
        return responseDto;
    }
}